Skip to content

BLOCK-52: Fix Code Block Pro text color and webfont loading - #81

Merged
zackkatz merged 1 commit into
developfrom
feature/block-52-code-block-pro-blocks-written-through-block
Nov 8, 2026
Merged

zackkatz merged 1 commit into
developfrom
feature/block-52-code-block-pro-blocks-written-through-block

Conversation

@zackkatz

@zackkatz zackkatz commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Code Block Pro blocks written through Block MCP rendered gray text on navy on docs pages, and two-digit line numbers broke onto two lines. Blocks written now match blocks made in the editor.

Fixes BLOCK-52

What changed

  • shikiHighlight(): every default-color token span gets style="color: var(--shiki-color-text)", as CBP's own output does. A bare <span> took the page's pre/code color, which is dark gray on BetterDocs.
  • syncWrapperFontFamily(): data-code-block-pro-font-family holds the bare fontFamily attribute. CBP's front-end script loads build/fonts/<value>.woff2, so the fallback stack there requested a file that does not exist. The webfont never loaded and the wider fallback font wrapped line numbers.

Blast radius

  • Touches: shikiHighlight() and syncWrapperFontFamily() in src/enrichers.ts
  • Used by: block-mcp only, src/enrichers.ts and its tests. Every Code Block Pro write goes through them.
  • Customer code: none
  • Docs: none
  • Risk: Contained

Release: none until the next Block MCP version bump (internal tool)

Testing

  • Two regression tests; both fail without the fix. Full suite: 965 passed.
  • Repaired the live block on Shortening the displayed URL in a Website field with this build: the webfont loads, tokens are colored, and line 10 is one line high.

💾 Build file (c219d9e).

Summary by CodeRabbit

  • Bug Fixes
    • Code blocks now consistently display highlighted text in the correct colors, including when rendered as HTML.
    • Code blocks use the configured font while retaining generic font fallbacks. Existing font metadata is preserved when no usable font is specified.
  • Documentation
    • Updated the changelog with fixes for code text colors, font loading, and line-number display.

Shiki leaves default-color tokens as bare <span>s, which inherit the page's
pre/code color (dark gray on BetterDocs). Every token span now carries
color: var(--shiki-color-text), as CBP's own output does.

data-code-block-pro-font-family held the full fallback stack, so CBP's
front-end script requested a font file that does not exist. It now holds
the bare fontFamily attribute.
@linear-code

linear-code Bot commented Nov 8, 2026

Copy link
Copy Markdown

BLOCK-52

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The enrichers and bundled MCP server now add text colors to unstyled token spans and update font metadata only when a usable font attribute is supplied. Tests cover the rendered colors and font values. The changelog describes the fixes.

Changes

Code Block Pro rendering

Layer / File(s) Summary
Color unstyled token spans
src/enrichers.ts, wordpress-plugin/gk-block-mcp/assets/mcp-server/index.cjs, src/__tests__/unit/enrichers/cbp-enricher.test.ts
The enrichers add the Shiki text color to spans without an explicit color. Tests check generated and rendered HTML for unstyled spans and verify plaintext color output.
Preserve font metadata
src/enrichers.ts, wordpress-plugin/gk-block-mcp/assets/mcp-server/index.cjs, src/__tests__/unit/enrichers/cbp-enricher.test.ts, wordpress-plugin/gk-block-mcp/readme.txt
The enrichers update font metadata only when a usable font attribute is supplied, using its trimmed value. Tests check the data attribute and CSS fallback stack. The changelog describes the text-color and code-font fixes.

Estimated code review effort: 2 (Simple) | ~10 minutes

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@zackkatz
zackkatz merged commit 174acf0 into develop Nov 8, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant